**********************************************************************************************

**** Replication for "Sanctions Removal in the Shadow of Bargaining Problems" ****

**** Author: Menevis Cilizoglu ****

**** Journal: Foreign Policy Analysis ****

**** Date Last Modified: 09/16/2022 ****

**********************************************************************************************

*Opening up data [please change the filepath/ working directory]

use "/Users/menevisc/Dropbox/Sanctions Removal Revisions_FPA/data for R&R/Cilizoglu_FPA_ReplicationData.dta", clear

log using "Cilizoglu_FPA_logfile.smcl", replace

*Table 2: Probit: Sanctions Removal (Please note that Table 2 omits the temporal controls, and Table S1 in Appendix B
*presents the same models presented in Table 2, but with the inclusion of temporal controls.)


*Table 2, Model 1
probit lift fraction_reported tradechange_div c.fraction_reported#c.tradechange_div tradedep multiissue multisender s2un jointigo cinct_s newsupport_s t t2 t3, robust cluster(targetstate)

*obtain AIC and BIC values
estat ic

*Table 2, Model 2
probit lift fraction_reported tradechange_div c.fraction_reported#c.tradechange_div tradedep multiissue multisender s2un jointigo cinct_s newsupport_s t t2 t3 if cost_s==0, robust cluster(targetstate)

*obtain AIC and BIC values
estat ic

*Figure 2: Marginal Effects of Information on the Probability of Sanctions Removal

*re-run Model 2 in Table 2
probit lift fraction_reported tradechange_div c.fraction_reported#c.tradechange_div tradedep multiissue multisender s2un jointigo cinct_s newsupport_s t t2 t3 if cost_s==0, robust cluster(targetstate)


preserve

set seed 339487731

drawnorm SN_b1-SN_b14, n(10000) means(e(b)) cov(e(V)) clear

*     ****************************************************************  *;
*       To calculate the desired quantities of interest we need to set  *;
*       up a loop.                                                      *;
*     ****************************************************************  *;
*       First, specify what you quantities should be saved and what     *;
*       these quantities should be called.                              *;
*     ****************************************************************  *;



postutil clear


*Change the filepath/ working directory first.
postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat diff_lo diff_hi using "/Users/menevisc/Dropbox/Sanctions Removal Revisions_FPA/data for R&R/sim.dta", replace
            
noisily display "start"
            
*     ****************************************************************  *;
*       Start loop.  Let `a' be the modifying variable Z and let this   *;
*       run from min to max in the desired increments.                  *;
*     ****************************************************************  *; 


local a= -9
while `a' <= 63 { 

{


scalar h_fraction_reported= .7641381
scalar h_tradechange_div=  4.336609
scalar h_tradedep= .2509018 
scalar h_multiissue= .2529412
scalar h_multisender= .2411765
scalar h_s2un= -.3734418
scalar h_jointigo= 39.59134
scalar h_newsupport_s= .3838235
scalar h_cinct_s= .0930126
scalar h_t= 6.166912
scalar h_t2= 85.90074
scalar h_t3= 2076.551
scalar h_constant=1

generate x_betahat0  = SN_b1*h_fraction_reported + SN_b2*`a' + SN_b3*h_fraction_reported*`a' + SN_b4*h_tradedep + SN_b5*h_multiissue + SN_b6*h_multisender + SN_b7*h_s2un + SN_b8*h_jointigo +SN_b9*h_newsupport_s+ SN_b10*h_cinct_s+ SN_b11*h_t+ SN_b12*h_t2 + SN_b13*h_t3 + SN_b14*h_constant 
                            
generate x_betahat1  = SN_b1*(h_fraction_reported+ .277676) + SN_b2*`a' + SN_b3*(h_fraction_reported+ .277676)*(`a') + SN_b4*(h_tradedep) + SN_b5*(h_multiissue) + SN_b6*(h_multisender) + SN_b7*(h_s2un) +SN_b8*(h_jointigo) + SN_b9*(h_newsupport_s) + SN_b10*(h_cinct_s) +SN_b11*(h_t)+SN_b12*(h_t2) +SN_b13*(h_t3) +SN_b14*(h_constant)
    	
	
    gen prob0 =normal(x_betahat0)
    gen prob1=normal(x_betahat1)
    gen diff=prob1-prob0
    
    egen probhat0 =mean(prob0)
    egen probhat1=mean(prob1)
    egen diffhat=mean(diff)
    
    tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat diff_lo diff_hi

    _pctile prob0, p(5,95)
    scalar `lo0' = r(r1)
    scalar `hi0' = r(r2) 
    
    _pctile prob1, p(5,95)
    scalar `lo1'= r(r1)
    scalar `hi1'= r(r2) 
    
    _pctile diff, p(5,95)
    scalar `diff_lo'= r(r1)
    scalar `diff_hi'= r(r2) 
   
    scalar `prob_hat0'=probhat0
    scalar `prob_hat1'=probhat1
    scalar `diff_hat'=diffhat
    
    post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') (`diff_hat') (`diff_lo') (`diff_hi')
   
    }

	drop x_betahat0 x_betahat1 prob0 prob1 diff probhat0 probhat1 diffhat
    
    local a=`a'+1
   
    display "." _c
    
} 

display ""

postclose mypost

*     ****************************************************************  *;                                  
*       Call on posted quantities of interest                           *;
*     ****************************************************************  *;

restore

*Change the filepath/ working directory
merge using "/Users/menevisc/Dropbox/Sanctions Removal Revisions_FPA/data for R&R/sim.dta"


gen yline=0

gen MV = (_n-9)

replace  MV=. if _n>70

gen where=-0.955
gen pipe = "|";

			
*rug plot embedded in the figure
			
			graph twoway scatter where tradechange_div if cost_s==0, plotr(m(b 4)) ms(none) mlabcolor(gs5) mlabel(pipe) mlabpos(6) legend(off) ///
        ||  line diff_hat MV, clwidth(medium) clcolor(blue) clcolor(black) ///
        ||  line diff_lo MV, clpattern(dash) clwidth(thin) clcolor(black) ///
        ||  line diff_hi MV, clpattern(dash) clwidth(thin) clcolor(black) ///
        ||  line yline MV,  clwidth(thin) clcolor(black) clpattern(solid) ///
        ||  , ///
            xlabel(-10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60, nogrid labsize(2)) ///
            ylabel(-.9 -.8 -.7 -.6 -.5 -.4 -.3 -.2 -.1 0 .1 .2 .3 .4, axis(1) nogrid labsize(2)) ///
            yscale(line) xscale(line) legend(off) ///
            yline(0, lcolor(black)) ///
            yline(.1 .3 .5 .7, lcolor(white)) ///
            xtitle("{&Delta} in Target's Trade Volume", size(2.5)) ///
            ytitle("Marginal Effect of 'Information'", size(2.5)) ///
            xsca(titlegap(4)) ysca(titlegap(4)) ///
            scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white))



log close


